package Question1;

import java.util.Scanner;
import java.util.Vector;

/**
 * Created by stevenfen on 2017/3/6.
 */
public class Main {
    public static long count = 0;
    private void fullPermutation(Vector<Character> sourse,Vector<Character> result){
        if(sourse.size()==0){
            for(int i =0;i<result.size();i++){
                System.out.print(result.elementAt(i));
            }
            System.out.println("");
            count++;
            return;
        }

        for(int i=0;i<sourse.size();i++){
            Vector<Character> tsource = new Vector<>(sourse);
            Vector<Character> tresult = new Vector<>(result);
            tresult.add(sourse.elementAt(i));
            tsource.remove(i);
            new Main().fullPermutation(tsource,tresult);
        }
    }

    public  static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        Vector<Character> sourse = new Vector<>();
        Vector<Character> result = new Vector<>();
        for(int i =0;i<n;i++){
            sourse.add((char)('A'+i));
        }

        new Main().fullPermutation(sourse,result);
    }
}
